package com.hdsx.jxcsxm.utile.http;

import org.apache.http.HttpEntity;
import org.apache.http.HttpResponse;
import org.apache.log4j.Logger;

import java.io.BufferedReader;
import java.io.InputStreamReader;
import java.util.ArrayList;
import java.util.Collection;
import java.util.List;

/**
 * zhaochunguang
 * @date 2015-7-17
 * @author 
 */
public class ResponseUtils {
	// private static Logger logger = Logger.getLogger(ResponseUtils.class);

   	 public static String getHttpEntityContent(HttpResponse response,String charset){
   	        try {
   	        	HttpEntity entity = response.getEntity();
           		BufferedReader br = new BufferedReader(new InputStreamReader(entity.getContent(),charset));
           		String line ="";
           		StringBuilder sb = new StringBuilder();
           		while ((line=br.readLine())!= null) {
           			sb.append(line);
           		}
           		//System.out.println("----------------getHttpEntityContent--------------"+sb.toString());
           		return sb.toString();
   			} catch (Exception e) {
   				// logger.error("获取【response】时出错：".concat(e.getMessage()));
   				return null;
   			}
   	    }
}
